/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.gui;

import com.domain.KBTAQuery;
import com.gui.exceptions.FailedToGetQuery;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.logging.Level;
import org.apache.log4j.Logger;

/**
 *
 * @author arkady
 */
public class FormListener extends QueryListener{
    private LinkedBlockingQueue<String> m_fileNameQueue;

    public FormListener(LinkedBlockingQueue<KBTAQuery> queryQueue) {
       super(queryQueue);
       s_logger = Logger.getLogger(FormListener.class);
       m_fileNameQueue = new LinkedBlockingQueue<String>();
       SubmitFilenameForm submitForm = new SubmitFilenameForm(m_fileNameQueue);
       submitForm.setVisible(true);
    }

    protected KBTAQuery getNextQuery() throws FailedToGetQuery{
        try {
            String fileName = m_fileNameQueue.take();
            s_logger.info("filename submitted :" + fileName);            
        } catch (InterruptedException ex) {
            s_logger.warn("Interrupted while sleeping on filenameQueue");
            throw new FailedToGetQuery();
        }
        return new KBTAQuery();
    }
}
